package com.thymeleaf.controller;

import com.thymeleaf.model.Clazz;
import com.thymeleaf.model.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

/**
 * Created by oracle on 2017-05-21.
 */
@Controller
@RequestMapping("/example")
public class ThymeleafController {
    @RequestMapping("/thymeleaf.html")
    public String thymeleaf(Map varables) {
        varables.put("company", "中科软科技股份有限公司");
        Clazz clazz = new Clazz();
        clazz.setClazzNo("001");
        clazz.setClazzName("1班");
        clazz.setExcellent(true);
        List<Student> students = new ArrayList<Student>();
        for (int t = 0; t < 29; t++) {
            Student student = new Student();
            student.setName("jhon" + t);
            student.setAge(20 + t);
            student.setSex(t % 2 == 0 ? "男" : "女");
            student.setStuNo("10000" + t);
            student.setBirthDay(new Date());
            student.setClazz(clazz);
            students.add(student);
        }
        clazz.setStudents(students);
        varables.put("clazz", clazz);
        return "example/thymeleafExample";
    }
}
